# 鼠标点击事件绑定将鼠标点击事件（<Button-1>）与我们自定义的 callback() 方法绑定起来
# import tkinter as tk
# window = tk.Tk()
# window.title('hello thinter')
# height = window.winfo_screenheight()
# width = window.winfo_screenwidth()
# window.geometry('400x300+%d+%d' % ((width - 400) / 2, (height - 300) / 2))

# def callback(event):
#     print("点击位置：", event.x, event.y)

# frame = tk.Frame(window, width=200, height=200)
# frame.bind("<Button-1>", callback)
# frame.pack()

# window.mainloop()


# 绑定键盘事件
# import tkinter as tk
# window = tk.Tk()
# window.title('hello thinter')
# height = window.winfo_screenheight()
# width = window.winfo_screenwidth()
# window.geometry('400x300+%d+%d' % ((width - 400) / 2, (height - 300) / 2))

# def callback(event):
#     print("点击的键盘字符为：", event.char)

# frame = tk.Frame(window, width=200, height=200)
# frame.bind("<Key>", callback)
# frame.focus_set()
# frame.pack()

# window.mainloop()



# 鼠标活动轨迹
import tkinter as tk
window = tk.Tk()
window.title('hello thinter')
height = window.winfo_screenheight()
width = window.winfo_screenwidth()
window.geometry('400x300+%d+%d' % ((width - 400) / 2, (height - 300) / 2))
def callback(event):
    print("当前位置为：", event.x, event.y)

frame = tk.Frame(window, width=200, height=200)
frame.bind("<Motion>", callback)
frame.pack()

window.mainloop()